import instance from './index.js'
import {
	encrypt,
	decrypt
} from '@/utils/crypto'

function encryptFun(data) {
	return {
		parameter: encrypt(data)
	}
}


// 账户信息
export const userInfo = (body) => {
	return instance({
		url: '/api/user/info',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 账户余额
export const userBalance = (body) => {
	return instance({
		url: '/api/user/balance',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 国家地区列表
export const defaultAreaList = (body) => {
	return instance({
		url: '/api/default/area_list',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 发送短信
export const notifySendSms = (body) => {
	return instance({
		url: '/api/notify/send_sms',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 发送邮件
export const notifySendEmail = (body) => {
	return instance({
		url: '/api/notify/send_email',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 注册
export const notifyRegister = (body) => {
	return instance({
		url: '/api/user/register',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 登录
export const userLogin = (body) => {
	return instance({
		url: '/api/user/login',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 忘记密码
export const userForgetPassword = (body) => {
	return instance({
		url: '/api/user/forget_password',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}


// 交易对列表
export const marketCurrencyMatches = (body) => {
	return instance({
		url: '/api/market/currency_matches',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 网络列表
export const marketNetworks = (body) => {
	return instance({
		url: '/api/market/networks',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 下注
export const microtradeSubmit = (body) => {
	return instance({
		url: '/api/microtrade/submit',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
} 


// 下注记录 status	类型 1交易中 3已平仓
export const microtradeLists = (body) => {
	return instance({
		url: '/api/microtrade/lists',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}


// 获取k线行情
export const marketKline = (body) => {
	return instance({
		url: '/api/market/kline',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}


// 获取赔率
export const microtradeOdds = (body) => {
	return instance({
		url: '/api/microtrade/odds',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 排行榜
export const microtradeRankingList = (body) => {
	return instance({
		url: '/api/microtrade/ranking_list',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// k线历史行情
export const marketHistoryKline = (body) => {
	return instance({
		url: '/api/market/history_kline',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// Tick历史行情
export const marketTickHistory = (body) => {
	return instance({
		url: '/api/market/tick_history',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 退出
export const userLogout = (body) => {
	return instance({
		url: '/api/user/logout',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
} 

// 修改密码
export const userAmendPassword = (body) => {
	return instance({
		url: '/api/user/amend_password',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
} 


// 规则
export const defaultSetting = (body) => {
	return instance({
		url: '/api/default/setting?key=rule',
		method: 'GET',
		params: {
			// ...encryptFun(body)
		}
	})
}

// 游客 最大下注金额
export const defaultSettingAmount = (body) => {
	return instance({
		url: '/api/default/setting?key=test_max_betting_amount',
		method: 'GET',
		params: {
			// ...encryptFun(body)
		}
	})
}


// 时长列表
export const microtradeSeconds = (body) => {
	return instance({
		url: '/api/microtrade/seconds',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}


// 游客登录
export const loginTest = (body) => {
	return instance({
		url: '/api/user/login_test',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

